﻿using System;
using Game.ui;
using GameFramework.common;
using GameFramework.data;
using GameFramework.events;
using UnityEditor;
using UnityEngine;
[Serializable]
[DataLocation(path = "AllData/MainPlayerData/BaseInfoData.json")]
public class BaseInfoData
{
    public String name;
    public String headIcon;
    public int level = 1;
    public long nowExp;
    public long maxExp;


    public BaseInfoData()
    {
        //可以提取到父类，modle类
        MVPEventManager.Instance.onViewShowListener<HomeView>(() =>
        {
            MVPEventManager.Instance.onViewModelPrepared(typeof(HomeView),this);
        });
        MVPEventManager.Instance.onViewShowListener<SetNamingView>(() =>
        {
            MVPEventManager.Instance.onViewModelPrepared(typeof(SetNamingView),this);
        });
    }


    public string Name
    {
        get => name;
        set
        {
            name = value;
            JsonUtil.writeData(this);
        }
    }
    public string HeadIcon
    {
        get => headIcon;
        set
        {
            headIcon = value;
            JsonUtil.writeData(this);
        }
    }
    public long NowExp
    {
        get => nowExp;
        set
        {
            nowExp = value;
            JsonUtil.writeData(this);
        }
    }
    public long MaxExp
    {
        get => maxExp;
        set
        {
            maxExp = value;
            JsonUtil.writeData(this);
        }
    }
    public override string ToString()
    {
        return "BaseInfoData:" + JsonUtility.ToJson(this);
    }
}